from marshmallow import Schema, fields, validate
from datetime import datetime

class DepartmentSchema(Schema):
    """科室模式"""
    name = fields.Str(required=True)
    code = fields.Str(required=True)
    description = fields.Str()
    location = fields.Str()
    floor = fields.Str()
    telephone = fields.Str()
    headDoctor = fields.Str()
    category = fields.Str(validate=validate.OneOf(['临床', '医技', '行政', '其他']), dump_default='临床')
    order = fields.Integer(dump_default=100)
    status = fields.Str(validate=validate.OneOf(['启用', '禁用']), dump_default='启用')
    createdAt = fields.DateTime(dump_default=datetime.utcnow)
    updatedAt = fields.DateTime(dump_default=datetime.utcnow)

class DepartmentUpdateSchema(Schema):
    """科室更新模式"""
    name = fields.Str()
    description = fields.Str()
    location = fields.Str()
    floor = fields.Str()
    telephone = fields.Str()
    headDoctor = fields.Str()
    category = fields.Str(validate=validate.OneOf(['临床', '医技', '行政', '其他']))
    order = fields.Integer()
    status = fields.Str(validate=validate.OneOf(['启用', '禁用']))

class DepartmentQuerySchema(Schema):
    """科室查询模式"""
    name = fields.Str()
    category = fields.Str(validate=validate.OneOf(['临床', '医技', '行政', '其他', 'all']))
    status = fields.Str(validate=validate.OneOf(['启用', '禁用', 'all'])) 